/**
 * 
 */
$(function() {
		$("#signupForm").validate({
			rules : {
				oldpassword : {
					required : true,
					minlength : 6,
					maxlength : 16
				},
				newpassword : {
					required : true,
					minlength : 6,
					maxlength : 16
				},
				confirm_password : {
					required : true,
					minlength : 6,
					maxlength : 16,
					equalTo : "#password"
				},
				agree : "required"
			},
			messages : {
				oldpassword : {
					required : "密码不能为空",
					minlength : "密码应为6~16位",
					maxlength : "密码应为6~16位"
				},
				password : {
					required : "密码不能为空",
					minlength : "密码应为6~16位",
					maxlength : "密码应为6~16位"
				},
				confirm_password : {
					required : "密码不能为空",
					minlength : "密码应为6~16位",
					equalTo : "密码应为6~16位"
				},
				agree : "Please accept our policy"
			},
			errorElement : "em",
			errorPlacement : function(error,
					element) {
				// Add the `help-block` class to the
				// error element
				error.addClass("help-block");
				if (element.prop("type") === "checkbox") {
					error.insertAfter(element
							.parent("label"));
				} else {
					error.insertAfter(element);
				}
			},
			highlight : function(element,
					errorClass, validClass) {
				$(element).parents(".col-md-9")
						.addClass("has-error")
						.removeClass("has-success");
			},
			unhighlight : function(element,
					errorClass, validClass) {
				$(element).parents(".col-md-9")
						.addClass("has-success")
						.removeClass("has-error");
			}
		});
});